<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <link href="https://cdn.bootcss.com/twitter-bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet">
    </head>
    <body>
        <div class="container">
            <div class="row clearfix">
                <div class="col-md-12 column">
                    <h1 class="text-center">
                        账目信息编辑
                    </h1>
                    <h3 class="text-right text-success">
                        欢迎您:XXX
                        <#--<@shiro.principal property="name" />-->
                    </h3>

                        <div class="container">
                            <div class="row clearfix">
                                <div class="col-md-12 column">
                                    <div class="row clearfix">
                                        <div class="col-md-2 column">
                                        </div>
        <div class="col-md-6 column">
            <form class="form-horizontal" role="form" id="form">
                <input type="hidden" value="${account.aid!}" name="aid">
                <div class="form-group">
                    <label for="itemId" class="col-sm-2 control-label">记账事项</label>
                    <div class="col-sm-10">
                        <select name="itemId" class="form-control" id="accountItem">
                            <option value="0">请选择菜单</option>
                            <#if itemList?exists>
                                <#list itemList as item>
                                    <option value="${item.id?if_exists}"
                                        <#if  (account.itemId??)>
                                            <#if item.id==account.itemId>selected</#if>
                                        </#if>
                                    >${item.content}</option>
                                    <#--<option value="${model.id?if_exists}" <#if menu.parentId== model.id>selected</#if>>${model.name}</option>-->
                                </#list>
                            </#if>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label for="operationDate" class="col-sm-2 control-label">业务日期</label>
                    <div class="col-sm-10">
                        <input type="date" class="form-control" id="operationDate"
                        name="operationDate" value="${account.operationDate?string('yyyy-MM-dd')}"/>
                    </div>
                </div>

                <div class="form-group">
                    <label for="contact" class="col-sm-2 control-label">关系人</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="contact"
                               name="contact" value="${account.contact!}"/>
                    </div>
                </div>

                <div class="form-group">
                    <label for="company" class="col-sm-2 control-label">往来单位</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="company"
                               name="company" value="${account.company!}"/>
                    </div>
                </div>

                <div class="form-group">
                    <label for="reason" class="col-sm-2 control-label">事由</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="reason"
                               name="reason" value="${account.reason!}"/>
                    </div>
                </div>

                <div class="form-group">
                    <label for="accountState" class="col-sm-2 control-label">进/出账</label>
                    <div class="col-sm-10">
                        <select name="accountState" class="form-control" id="accountState">
                            <option value="-1">请选择菜单</option>
                            <option value="1"
                                <#if  (account.accountState??)>
                                    <#if account.accountState==1>selected</#if>
                                </#if>
                            >进账</option>
                            <option value="0"
                                <#if  (account.accountState??)>
                                    <#if account.accountState==0>selected</#if>
                                </#if>
                            >出账</option>

                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label for="money" class="col-sm-2 control-label">金额(元)</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="money" name="money"
                               value="${account.money?c!}"/>
                    </div>
                </div>

                <div class="form-group">
                    <label for="car" class="col-sm-2 control-label">相关车辆</label>
                    <div class="col-sm-10">
                        <input type="car" class="form-control" id="car" name="car"
                               value="${account.car!}"/>
                    </div>
                </div>

                <div class="form-group">
                    <label for="recorder" class="col-sm-2 control-label">记录人</label>
                    <div class="col-sm-10">
                        <input type="car" class="form-control" id="recorder"
                               value="${account.recorder!}" readonly/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="recordeTime" class="col-sm-2 control-label">记录日期</label>
                    <div class="col-sm-10">
                        <input type="date" class="form-control" id="recordeTime"
                                value="${account.recordeTime?string('yyyy-MM-dd')}" readonly/>
                    </div>
                </div>

                <div class="form-group">
                    <label for="checkState" class="col-sm-2 control-label">审核状态</label>
                    <div class="col-sm-10">
                        <input type="checkState" class="form-control" id="checkState"
                               value="${account.checkState!}" readonly/>
                    </div>
                </div>

                <div class="form-group">
                    <label for="tradeState" class="col-sm-2 control-label">确认状态</label>
                    <div class="col-sm-10">
                        <input type="tradeState" class="form-control" id="tradeState"
                               value="${account.tradeState!}" readonly/>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="button" class="btn btn-success"
                        onclick="accountSubmit()">提交</button>
                        &nbsp;&nbsp;&nbsp;
                        <button type="button" class="btn btn-success"
                                onclick="history.back()">返回</button>
                    </div>
                </div>
            </form>
        </div>
            <div class="col-md-4 column">
                <div class="form-group">
                </div>
            </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <script src="/static/js/jquery-1.8.0.min.js" ></script>
        <script>
            // // 添加账目信息
            // function accountSubmit(){
            //     //1. 获取form表单中的全部内容
            //     var data = $("#form").serialize(); //将携带name属性的表单项拼接为key=value&key=value..
            //     //2. 发送ajax请求到后台,并传递全部的参数.
            //     $.post(
            //         "/account/edit",
            //         data,
            //         function(result){
            //             if(result.code == 0){
            //                 alert(result.msg)
            //                 location.href = "/account/list";
            //             }else {
            //                 alert(result.msg)
            //             }
            //         },
            //         "json"
            //     );
            // }

            // 添加账目信息
            function accountSubmit() {
                //1. 获取form表单中的全部内容
                var data = $("#form").serialize(); //将携带name属性的表单项拼接为key=value&key=value..
                //2. 发送ajax请求到后台,并传递全部的参数.
                $.ajax({
                    type: "POST",
                    url: "/account/edit",
                    data: data,
                    success: function (result) {
                        if (result.code == 0) {
                            alert(result.msg)
                            location.href = "/account/list";
                        } else {
                            alert(result.msg)
                        }
                    },
                    error: function (XMLHttpRequest) {
                        alert("Error: " + XMLHttpRequest.responseText);
                    }
                });
            }
        </script>
    </body>
</html>